﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HighDivePrint.Model;
using HighDivePrint.View;

namespace HighDivePrint.Presenter
{
    public class PresenterFormMain
    {
        #region Fields/Variables
        #endregion

        #region Properties

        public IFormMain _view { get; set; }

        public IPersonList _diver { get; set; }

        public IDiveList _dive { get; set; }
        #endregion

        #region Constructor
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="view"></param>
        /// <param name="cr"></param>
        
        public PresenterFormMain(IFormMain view, PersonList pl, DiveList dl)
        {
            this._diver = pl;
            this._view = view;
            this._view.SetDiverList(pl.List);
            this._view.EventNewDiver += NewDiver;
            this._view.EventDeleteDiver += DeleteDiver;
            this._view.EventSaveToFile += SaveToFile;
            this._view.EventReadFromFile += ReadFromFile;

            this._dive = dl;
            this._view.SetDiveList(dl.List);
            this._view.EventAddToList += AddToList;
            this._view.EventRemoveFromList += RemoveFromList;
            this._view.EventSaveList += SaveList;
            this._view.EventReadList += ReadList;
        }

        #endregion

        public void NewDiver()
        {
            this._diver.Add(new Diver());
        }

        public void DeleteDiver(int index)
        {
            this._diver.Remove(index);
        }

        public void SaveToFile()
        {
            this._diver.SaveToFile();
        }

        public void ReadFromFile()
        {
            this._diver.ReadFromFile();
        }

        public void AddToList()
        {
            this._dive.AddToList(new Dive());
        }

        public void RemoveFromList(int index)
        {
            this._dive.RemoveFromList(index);
        }

        public void SaveList()
        {
            this._dive.SaveList();
        }

        public void ReadList()
        {
            this._dive.ReadList();
        }
    }
}
